p=input()
bo="([{<"
bc=")]}>"
stack=[]
brack_match = True
for i in p:
         if i in bo:
                  stack.append(i)
         if i in bc:
                  if len(stack) == 0 or bc.find(i) != bo.find(stack.pop()):
                           brack_match = False
                           break
if len(stack) == 0 and brack_match:
         print("True")
else:
         print("False")
